home *** CD-ROM | disk | FTP | other *** search
- Path: waldorf.csc.calpoly.edu!galaxy!ostoll
- From: ostoll@galaxy.csc.calpoly.edu (Oliver Stoll)
- Newsgroups: comp.lang.c++
- Subject: Re: help: template class, #include myclass.cpp?
- Date: 5 Mar 1996 22:09:07 GMT
- Organization: Cal Poly Computer Science Dept.
- Message-ID: <4hie23$5dd@waldorf.csc.calpoly.edu>
- References: <4h763j$2dv@jake.esu.edu>
- NNTP-Posting-User: ostoll@galaxy.csc.calpoly.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Jian Pan (pan7064@kutztown.edu) wrote:
- : when I declare a template class in a header file myclass.h and define the
- : class (implementation) in a .cpp file myclass.cpp, in my application
- : if I only include the .h file, there will be link error, "unresolved
- : external symbol", if I include the .cpp file, everything is OK.
- : If in the .h file is non template class, without including the .cpp file
- : there is no problem.
-
- : What is my problem? I am using VC++ 4.0. Using Borland C++ 4.5, I met the
- : same problem.
-
- : Any help will be greatly appreciated.
-
- : Jian
-
- : pan7064@kutztown.edu
-
-
- A template is no real function definition but merely a rule for the compiler
- to generate a function or class. Therefore the 'implementation' of the template
- functions have to go in the header file, or on instatiating the template
- with a class, the compiler does not know how to emit the code you want to
- generate.
-
-
-
-
- --
- -------------------------------------------------------------------------------
- Oliver "Oyl McDoyle" Stoll
-
- Fachhochschule Karlsruhe California Polytechnic State
- stol0012@fh-karlsruhe.de University (San Luis Obispo)
- http://www.fh-karlsruhe.de/~stol0012 ostoll@galaxy.csc.calpoly.edu
-